package com.dai.rpc.util;

import com.dai.rpc.compress.Compress;
import com.dai.rpc.constant.CompressTypeEnum;
import com.dai.rpc.exceptions.MyRpcException;
import com.dai.rpc.loadbanlance.LoadBalance;

import java.util.ServiceLoader;

public class SPIUtils {


    public static LoadBalance loadBalance(String name){

        ServiceLoader<LoadBalance> load = ServiceLoader.load(LoadBalance.class);
        for (LoadBalance loadBalance : load) {
            if(loadBalance.name().equals(name)) return loadBalance;
        }
        throw new MyRpcException("未找到对应的负载均衡器");
    }
}
